import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_app/main/content/model/content_model.dart';
import 'package:webview_flutter/webview_flutter.dart';

class ContentWidget extends StatefulWidget {
  static const RouteName = "/main/content";

  const ContentWidget({super.key});

  @override
  ContentPage createState() => ContentPage();
}

class ContentPage extends State<ContentWidget> {
  @override
  Widget build(BuildContext context) {
    final contentModel =
        ModalRoute.of(context)!.settings.arguments as ContentModel;
    print("link -> ${contentModel.link}");
    return Scaffold(
      body: Container(
        width: double.infinity,
        height: double.infinity,
        padding: const EdgeInsets.fromLTRB(0, 30, 0, 0),
        color: Colors.white,
        child: WebView(
          initialUrl: contentModel.link,
        ),
      ),
      floatingActionButton: Card(
        shadowColor: Colors.white,
        shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(30),
            side: const BorderSide(color: Colors.transparent, width: 2)),
        color: Colors.white,
        child: IconButton(
          icon: const Icon(
            Icons.arrow_back_rounded,
            size: 25,
            color: Colors.black,
          ),
          onPressed: () {
            Navigator.of(context).pop();
          },
          style: ElevatedButton.styleFrom(shape: const CircleBorder()),
        ),
      ),
    );
  }
}
